vpci: don't assume that vpci per-device data exists unconditionally
authorRoger Pau Monné <roger.pau@citrix.com>
Mon, 31 Oct 2022 12:25:13 +0000 (13:25 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 31 Oct 2022 12:25:13 +0000 (13:25 +0100)
commit96d26f11f56e83b98ec184f4e0d17161efe3a927
tree28e4be4cbc699ac561d41e403255bf48b5d62c3b
parent9fdb4f17656f74b35af0882b558e44832ff00b5f
vpci: don't assume that vpci per-device data exists unconditionally

It's possible for a device to be assigned to a domain but have no
vpci structure if vpci_process_pending() failed and called
vpci_remove_device() as a result.  The unconditional accesses done by
vpci_{read,write}() and vpci_remove_device() to pdev->vpci would
then trigger a NULL pointer dereference.

Add checks for pdev->vpci presence in the affected functions.

Fixes: 9c244fdef7 ('vpci: add header handlers')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: 6ccb5e308ceeb895fbccd87a528a8bd24325aa39
master date: 2022-10-26 14:55:30 +0200
xen/drivers/vpci/vpci.c